﻿using System.Security.Claims;
using BilbilBLL;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace bilbil.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class VideoHistoryController : ControllerBase
    {
        /// <summary>
        /// 获取今天观看过的视频记录
        /// </summary>
        /// <param name="UserInfoId"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public IActionResult GetVideoHistoryToday() 
        {
            int userInfoId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            return new JsonResult(new VideoHistoryServer().GetVideoHistoryToday(userInfoId));
        }
        /// <summary>
        /// 获取昨天观看过的视频记录
        /// </summary>
        /// <param name="UserInfoId"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public IActionResult GetVideoHistoryYesterday()
        {
            int userInfoId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            return new JsonResult(new VideoHistoryServer().GetVideoHistoryYesterday(userInfoId));
        }
        /// <summary>
        /// 获取更久之前的视频记录
        /// </summary>
        /// <param name="UserInfoId"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public IActionResult GetVideoHistoryALongTimeAgo()
        {
            int userInfoId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            return new JsonResult(new VideoHistoryServer().GetVideoHistoryALongTimeAgo(userInfoId));
        }
    }
}
